package dxn.nl.file.api.export;

import dxn.nl.file.client.core.CsExportDealServer;
import dxn.nl.file.client.core.DealExportService;
import dxn.nl.file.client.model.dto.*;
import dxn.nl.file.client.model.enums.ExportDealResultTypeEnum;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@Component
@CsExportDealServer(value = {"demo_export_page_not_title"})
public class DealPageNoTitleExport implements DealExportService {
    @Override
    public CsExportDealTypeHeadDto getExcelHeads(TransferMessageConfig config, TransferMessageData messageData, byte[] data) {
        List<CsExportExcelHeadDto> dtoList = Arrays.asList();
        //List<CsExportExcelHeadDto> dtoList = Arrays.asList(new CsExportExcelHeadDto("a","name",1));
        CsExportDealTypeHeadDto dto = CsExportDealTypeHeadDto.pageDeal(dtoList);
        return dto;
    }

    @Override
    public  CsExportDealResult queryData(TransferMessageConfig config, TransferMessageData messageData, byte[] data) {
        CsExportDealResult dealResult = new CsExportDealResult();
        dealResult.setDealResult(ExportDealResultTypeEnum.continue_deal);

        //
        if(messageData.getCurrentParam()!=null) {
            dealResult.setDealResult(ExportDealResultTypeEnum.end);
            return dealResult;
        }

        // CurrentParam 当前处理的参数，每次调用都会将最新的传递过来
        dealResult.setCurrentParam("ceshi");
        List<List<String>> list = new ArrayList<>();
        list.add(Arrays.asList("ceshi1","ceshi2"));
        list.add(Arrays.asList("航1","航2","航3"));
        list.add(Arrays.asList("尾部1"));
        dealResult.setData(list);

        return dealResult;
    }
}
